﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lilium.Web.Mvc.EntityFilters
{
    public sealed class PagerState : ICloneable, IEquatable<PagerState>
    {
        #region public int PageIndex

        private int m_PageIndex;

        public int PageIndex
        {
            get
            {
                return m_PageIndex;
            }
            set
            {
                m_PageIndex = value;
            }
        }

        #endregion

        #region public int PageSize

        private int m_PageSize;

        public int PageSize
        {
            get
            {
                return m_PageSize;
            }
            set
            {
                m_PageSize = value;
            }
        }

        #endregion

        #region ICloneable Members

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        #endregion

        public override bool Equals(object obj)
        {
            var other = obj as PagerState;
            if (other != null)
                return Equals(other);
            else
                return base.Equals(obj);
        }

        public override int GetHashCode()
        {
            return PageIndex.GetHashCode() ^ PageSize.GetHashCode();
        }

        #region IEquatable<PagerState> Members

        public bool Equals(PagerState other)
        {
            if (other != null)
                return this.PageIndex == other.PageIndex
                    && this.PageSize == other.PageSize;
            else
                return false;
        }

        #endregion
    }
}